#ifndef __clib_list_arr_h__
#define __clib_list_arr_h__

#include <inttype.h>

typedef int lta_iterator;

typedef struct _list_arr
{
    void*** val;
    int size;
    int bound;
    int bsorted;
} list_arr;

/// create a new list
list_arr* lta_create();
/// destroy an existed list
void lta_destroy( list_arr* _lt );
/// get the count of datas in the list
int32 lta_size( list_arr* _lt );

/// push data to the back of the list
void lta_pushb( list_arr* _lt, void* _val );
/// push data to the front of the list
void lta_pushf( list_arr *_lt, void *_val );
/// insert a new data to the list, behind the iterator
lta_iterator lta_insert( list_arr *_lt, lta_iterator _it, void *_val );
/// insert a new data to the list, at the pos-th position
/// 0 <= _pos < ltc_size()
lta_iterator lta_insertp( list_arr *_lt, int32 _pos, void *_val );

/// get the value of iterator
void* lta_val( lta_iterator _it );
/// get the pos-th data in the list
void* lta_get( list_arr *_lt, int32 _pos );
/// get the data at the front of the list
void* lta_front( list_arr *_lt );
/// get the data at the back of the list
void* lta_back( list_arr *_lt );
/// get the first iterator
lta_iterator lta_begin( list_arr *_lt );
/// get the last position, which is next to the last data(insertion 
/// place), of the list
lta_iterator lta_end( list_arr *_lt );
/// get the next to the iterator
lta_iterator lta_next( lta_iterator _it );
/// get the previous to the iterator
lta_iterator lta_pre( lta_iterator _it );
/// get the first iterator which data matches the key.
/// fun( _key, ltc_val(iterator) ) == 0 means the iterator matches
/// the key
lta_iterator lta_find( list_arr *_lt, void *_key, compare _fun );

// the following functions will delete data from list
// {3 delete begin

/// list pop front
void* lta_popf( list_arr* _lt );
/// list pop back
void* lta_popb( list_arr *_lt );
/// remove the iterator( and it's data from list )
/// return the data
void* lta_remove( list_arr *_lt, lta_iterator _it );
/// remove the pos-th data from the list
/// return the data
void* lta_removep( list_arr *_lt, int32 _pos );

// delete finished 3}

// sort ascend the list.
void lta_sort( list_arr *_lt, compare _fun );


#endif // __clib_list_arr_h__
